﻿using JESAI.Redis.Abstracts;
using JESAI.Redis.Abstracts.Commadns;
using JESAI.Redis.Abstracts.Commands;
using JESAI.Redis.Abstracts.RedisClients;
using JESAI.Redis.Abstracts.Resolvers;
using JESAI.Redis.Builders;
using JESAI.Redis.Events;
using JESAI.Redis.RedisClients;
using JESAI.Redis.Resolvers;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace JESAI.Redis.Commands
{
    public partial class RedisCommand : IRedisCommand
    {
        private readonly IObjectInstancePool<IRedisClient> _redisClientPool;
        private readonly IRedisResolver _redisResolver;

        #region Events
        public void RegisterCommandExecutedEvent(EventHandler<CommandExecutedEventArgs> eventHandler)
        {

        }

        public void RegisterCommandExecuteEvent(EventHandler<CommandExecuteEventArgs> eventHandler)
        {

        }

        public void UnRegisterCommandExecutedEvent(EventHandler<CommandExecutedEventArgs> eventHandler)
        {

        }

        public void UnRegisterCommandExecuteEvent(EventHandler<CommandExecuteEventArgs> eventHandler)
        {

        }

        #endregion

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        internal static async Task<RedisCommand> BuilderAsync(IConnectionBuilder connectionBuilder)
        {
            var redisCommand = new RedisCommand(await RedisClientPool.BuildAsync(connectionBuilder));
            //连接配置
            return redisCommand;
        }



        internal RedisCommand(IObjectInstancePool<IRedisClient> redisClientPool, IRedisResolver redisResolver)
        {
            _redisClientPool = redisClientPool;
            _redisResolver = redisResolver;
        }

        private RedisCommand(IObjectInstancePool<IRedisClient> redisClientPool)
        {
            _redisClientPool = redisClientPool;
            _redisResolver = new DefaultRedisResolver(redisClientPool);
        }
    }
}
